import {
    msg,
    close,
    getQueryStringFromHash
} from '../../common/utils.js';
import Vue from 'vue';
import {
    serverPath,
    json
} from '../../common/config.js';
import GradesService from '../services/gradesService.js';

window.Module = function(){
    
    let gradesService = new GradesService();
    return new Vue({
        el: '#detailPageController',
        data: {
            entity: {

            }
        },
        methods:{
            init:async function(){
                let id = getQueryStringFromHash('id');
                if(!id)
                    close();
                let res =await gradesService.getGradesById(id);
                if(json == res.type){
                    var response = res.body;
                    if('Success' === response.result){
                        this.entity = response.data;
                    }
                    else{
                        await msg(response.message);
                    }
                }
            },
            close:function(){
                close();
            }
        }
    });
}